import { UploadFormCommon } from '@/components/UploadForm';
import { OneModal } from '@/components/one-ui';
import { IOneModalRef } from '@/pages/type';
import { Form } from 'antd';
import { Ref, useRef } from 'react';
import { getCompanyID, getPosIDs, getUserDepID, getUserID } from '@/utils';
export const UploadFileModal = ({ onClose }) => {
  /**弹框的ref*/
  const updateModalRef: Ref<IOneModalRef> = useRef(null);

  // 表单实例
  const [formRef] = Form.useForm();

  return (
    <OneModal
      open={true}
      getContainer={false}
      ref={updateModalRef}
      title={'上传'}
      onCancel={onClose}
      onOk={() => {}}
      width={document.body.clientWidth * 0.25}
      bodyStyle={{ padding: '5px 0px' }}
    >
      <Form>
        <UploadFormCommon
          form={formRef}
          fileFormName={''}
          spanCol={24}
          inRowProportion={24}
          name={'attachFile'}
          required={false}
          accept={'.doc|.docx|.xlsx'}
          url={`/materialController/import/${getUserID()}/${getPosIDs()}/${getUserDepID()}/${getCompanyID()}`}
          downloadUrl={'/purchaseSourceController/downloadFile'}
          fileFormDelName={'delFile'}
          maxFile={1}
          hintTitle={'且只能上传 1 个！'}
          defaultFiles={null}
          delFunc={function (delFilePath: string, attachmentPath: any): void {
            throw new Error('Function not implemented.');
          }}
          fieldBusiPath={'purchase/material'}
        >
          上传文件
        </UploadFormCommon>
      </Form>
    </OneModal>
  );
};
